#include <iostream>
#include <string>
#include "person.pb.h"
using namespace std;

string pro_str;
void set_person()
{
    Person obj;
    obj.set_name("mike");
    obj.set_id(1);
    //obj.set_email("mike@qq.com")

    *obj.mutable_email()="mike@qq.com";

    //
    //obj.SerializeToArray(arr,len);
    obj.SerializeToString(&pro_str);


}

void get_person()
{
    Person p;
//   p.ParseFromArray(arr,len);
    p.ParseFromString(pro_str);
    cout << "name:"<<p.name()<<endl;
    cout << "id:"<<p.id()<<endl;
    cout << "email:"<<p.email()<<endl;


}

int main()
{
    GOOGLE_PROTOBUF_VERIFY_VERSION;
    set_person();
    get_person();
    google::protobuf::ShutdownProtobufLibrary();
    return 0;
}
